package com.yixun.qfbao.hander;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yixun.qfbao.api.service.CompanyService;
import com.yixun.qfbao.apidto.GetCompanyByPhoneReqDto;
import com.yixun.qfbao.apidto.GetCompanyByPhoneResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetCompanyByPhoneReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * @Description
 * @Date 2017/12/28
 * @Author shaopingjiao
 * @Computer Administrator
 */
@Service("getCompanyByAssistantPhoneHander")
public class GetCompanyByAssistantPhoneHander extends CommonAbstractHander {
	
	private static final Logger logger = LoggerFactory.getLogger(GetCompanyByAssistantPhoneHander.class);
	
	@Autowired
	CompanyService companyService;
	
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		GetCompanyByPhoneReqVo req = (GetCompanyByPhoneReqVo)reqDto;
		GetCompanyByPhoneReqDto getCompanyByPhoneReqDto = req.getParams();
		BaseResponseDTO<GetCompanyByPhoneResDto> res = new BaseResponseDTO<GetCompanyByPhoneResDto>();
		GetCompanyByPhoneResDto resDto = new GetCompanyByPhoneResDto();
		try {
			resDto = companyService.getCompanyByAssistantPhone(getCompanyByPhoneReqDto);
		} catch (Exception e) {
			logger.error("通过手机号查找合作商失败: {}", e);
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg("获取合作商失败!");
		}
		res.setResData(resDto);
		res.setResult(resDto.getResult());
		return res;
	}
}
